package com;

import java.net.URI;

import com.netflix.client.ClientFactory;
import com.netflix.client.http.HttpRequest;
import com.netflix.client.http.HttpResponse;
import com.netflix.config.ConfigurationManager;
import com.netflix.loadbalancer.ZoneAwareLoadBalancer;
import com.netflix.niws.client.http.RestClient;

public class RibbonDemo 
{
    public static void main( String[] args ) throws Exception
    {
    	 RestClient client = (RestClient)ClientFactory.getNamedClient("RibbonDemo");  
         HttpRequest request = HttpRequest.newBuilder().uri(new URI("/hello")).build();  
           
           
         ConfigurationManager.getConfigInstance().setProperty("RibbonDemo.ribbon.listOfServers", "ekserver1:8080,ekserver2:8080");  
           
         Thread.sleep(3000);  
           
         for(int i = 0; i < 10; i ++) {  
             HttpResponse response = client.executeWithLoadBalancer(request);  
             System.out.println("Status for URI:" + response.getRequestedURI() + " is :" + response.getStatus());
             System.out.println("Result is:" + response.getEntity(String.class));
         }  
  
    }
}
